package com.ruoyi.ly.mapper;

import com.github.pagehelper.Page;
import com.ruoyi.ly.domain.SpaceFloor;
import com.ruoyi.ly.domain.dto.PageSpaceFloorDTO;
import com.ruoyi.ly.domain.vo.PageSpaceFloorVO;
import com.ruoyi.ly.domain.vo.SpaceFloorVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SpaceFloorMapper {

    // 更新空间楼层信息
    void update(SpaceFloor spaceFloor);

    // 插入空间楼层信息
    void insert(SpaceFloor spaceFloor);

    // 分页查询空间楼层信息
    Page<PageSpaceFloorVO> pageQuery(PageSpaceFloorDTO pageSpaceFloorDTO);

    // 根据楼层ID删除空间楼层信息
    @Delete("delete from space_floor where floor_id = #{floorId}")
    void delete(Long floorId);

    // 根据楼层ID查询空间楼层信息
    @Select("select sf.project_id,sf.imgs,sf.floor_area,sf.floor_number,sf.ban_id,sb.ban_name,sb.group_id,p.project_name from space_floor sf left join project p on sf.project_id = p.id left join space_ban sb on sf.ban_id = sb.ban_id where sf.floor_id = #{floorId}")
    SpaceFloorVO selectById(Long floorId);

    @Select("select sf.*,sb.ban_name,sb.group_id,p.project_name,sb.ban_address from space_floor sf left join project p on sf.project_id = p.id left join space_ban sb on sf.ban_id = sb.ban_id")
    List<PageSpaceFloorVO> selectAll();

    //查询所有楼层
    @Select("select * from space_floor where ban_id = #{banId} order by floor_number")
    List<SpaceFloor> selectAllFloor(Long banId);

    //根据banId查询对应楼栋所有楼层集合
    @Select("select floor_number from space_floor where ban_id = #{banId}")
    List<Long> selectAllFloorByBanId(Long banId);

    //根据floorId查询对应楼层号
    @Select("select floor_number from space_floor where floor_id = #{floorId}")
    Long selectFloorNumberByFloorId(Long floorId);
}
